<h2 id="title">修改文件夹</h2>
<p>note : 只有管理员才有权限操作目录</p>
<div id="otherInfo">
	<input id="id" type="hidden">
	<div class="fitem">
		<label>名称:</label>
		<input id="name" name="name" style="width:145px" class="easyui-validatebox" required="true">
	</div>
	<div class="fitem">
		<label>可见性:</label>
		<input id="resourceLevel" name="level" style="width:150px" class="easyui-validatebox" required="true">
		<br>
		<label></label><span id="comment"> 公开模式:用户可以自由在当前文件夹下添加文件、文件夹</span>
	</div>
	<div class="fitem">
		<label>描述:</label>
		<textarea  id="desc" name="desc" style="width:200px"></textarea>
	</div>
	
	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:updateFolderJs.update()">更新</a>
</div>

<script type="text/javascript">
(function(updateFolderJs, $, undefined ) {
	updateFolderJs.init = function(){
		
		var id = fileActionJs.getId();
		$('#id').val(id);
		workbenchJs.loadData("dispatch/utility/file/query?type=folder&id="+id,updateFolderJs.loadFolderResult,"加载文件夹信息");
		$('#resourceLevel').combobox({
			url:null,
			valueField:'value',
			textField:'name',
			multiple:false,
			panelHeight:'auto',
			data:[
			      {name:"公开",value:"Public",selected:true},
			      {name:"受保护",value:"Protected"},
			      {name:"私有",value:"Private"}],
			onSelect : function(record){
				setLevelComment(record.value);
			}
		});
		
	};
	function setLevelComment(value)
	{
		if(value == 'Public')
			$('#comment').html('公开模式:用户可以自由在当前文件夹下添加文件、文件夹');
		if(value == 'Protected')
			$('#comment').html('受保护模式:通过设置权限限制文件夹的访问和操作');
		if(value == 'Private')
			$('#comment').html('私有模式:只有管理员才能访问');
	}

	updateFolderJs.loadFolderResult = function(result){
    	var res = result.result;
        if(res == "SUCCESS")
        {
        	var value = jQuery.parseJSON(result.payload.value);
        	$('#desc').val(value.description);
        	$('#name').val(value.name);
        	$('#resourceLevel').combobox('setValue',value.level);
        	setLevelComment(value.level);
        }else if(res == "COMPONENT_ERROR")
        {
        	$.messager.alert("Error",result.payload.value);
        }else
        {
        	$.messager.alert("Error",result.result);
        }
	};
	updateFolderJs.update = function(){
    	var json = {};
    	json.id = parseInt($('#id').val());
    	json.name = $("#name").val();
    	json.description = $("#desc").val();
    	json.level = $('#resourceLevel').combobox('getValue');
		
    	var str = $.toJSON(json);
    	str = 'parameters='+str;
    	
		$.ajax({
            type: "post",
            url: 'dispatch/utility/folder/update',
            dataType:"json",
            data: str,
            cache: false,
            success: function (result) {
            	var res = result.result;
                if(res == "SUCCESS")
                {
                	var callback = fileActionJs.getCallBack();
                	callback(result);
                	
                }else if(res == "COMPONENT_ERROR")
                {
                	$.messager.alert("Error",result.payload.value);
                }else
                {
                	$.messager.alert("Error",result.result);
                }
                
            }
            
        });
	}
}( window.updateFolderJs = window.updateFolderJs || {}, jQuery ));

    $(function(){
    	updateFolderJs.init();
    });
</script>
 <style type="text/css">
        .ftitle{
            font-size:14px;
            font-weight:bold;
            padding:5px 0;
            margin-bottom:10px;
            border-bottom:1px solid #ccc;
        }
        .fitem{
            margin-bottom:5px;
        }
        .fitem label{
            display:inline-block;
            width:80px;
        }
        #comment{
        	padding:3px;
        }
 </style>